{extend name="base"/}
{block name="title"}
    商品详情
{/block}
{block name="css"}
<link rel="stylesheet" href="__MOBILE__/css/zhang.css">
{/block}
{block name="content"}

<!-- loading -->
<div id="loading">
    <div class="spinner-box">
        <div class="pulse-container">  
          <div class="pulse-bubble pulse-bubble-1"></div>
          <div class="pulse-bubble pulse-bubble-2"></div>
          <div class="pulse-bubble pulse-bubble-3"></div>
        </div>
    </div>
</div>
<!--end loading -->

<div class="head">
    <div class="head_left"><a href="javascript:history.go(-1)"><img src="__MOBILE__/images/true.png" alt=""></a></div>
    <div class="head_con">商品详情</div>
    <div class="head_right"></div>
</div>
        <div class="swiper-container myimg">
            <div class="swiper-wrapper imgbox">
              {volist name='goods_list.img1' id='row'}
                <div class="swiper-slide"><img src="{$row}"></div>
                <!-- <div class="swiper-slide"><img src="__MOBILE__/images/prod.png"></div> -->
              {/volist}
            </div>
            <div class="swiper-pagination"></div>
        </div> 
    <input type="hidden" name="good_id" value="{$goods_list.id}" />
    <div class="puct">
        <p>￥ {$goods_list.wallet_num} GMOB+ {$goods_list.integral_num}GMOD</p> 
        <p>{$goods_list.name} </p>
        {if $goods_list['bis_id'] != 0}<p>库存：{$goods_list.amount}</p>{/if}
    </div>
{if $goods_list['bis_id'] != 0}
    <div class="cond">
        <!-- <div class="color">
            <p>颜色</p>
            <ul class="color_s">
                <li class="active">黑色</li>
                <li>红色</li>
                <li>白色</li>
            </ul>
        </div>
        <div class="big">
            <p>尺寸</p>
            <ul class="chicun">
                <li class="active">S</li>
                <li>M</li>
                <li>XL</li>
                <li>XXL</li>
            </ul>
        </div> -->
        <div class="goodsnum">
            <p>数量</p>
            <div class="jian">-</div><input type="number" value="1" id="num"><div class="jia">+</div>
        </div>
    </div>
{else/}
<input type="hidden" value="1" id="num"><div class="jia">
{/if}
    <!--<div class="store">
        <img src="__MOBILE__/images/touxiang.png" alt="" class="dianpuname">
        <div class="store_con">
            <p>小草的旗舰店</p>
            <ul class="xing">
                <li><img src="__MOBILE__/images/xing.png" alt=""></li>
                <li><img src="__MOBILE__/images/xing.png" alt=""></li>
                <li><img src="__MOBILE__/images/xing.png" alt=""></li>
                <li><img src="__MOBILE__/images/xing.png" alt=""></li>
                <li><img src="__MOBILE__/images/xing.png" alt=""></li>
            </ul>
        </div>
        <a href="###" class="inshop">进店</a>
    </div>-->
    {if $goods_list['bis_id'] != 0}
    <ul class="evals">
        <li class="active">详情</li>
        <li>评价</li>
    </ul>

    <div class="united">{$goods_list['detail']|RAW}</div>
    <div class="united" style="display:none;">
                {if $record}
                {volist name='record' id='row'}
                <p><span>{$row.user_name}</span> <span>{$row.num}<em></em></span><span>{$row.create_time|date='Y-m-d'}</span></p>
                {/volist}
                {else/}
                <p style="text-align: center;">暂无成交记录</p>
                {/if}
    </div>
    {/if}
    <div class="bot">
        {if $goods_list['bis_id'] != 0}
        <a href="javascript:void(0)" onclick="showParams();">加入购物车</a>
        {else /}
        <a href="###" id="goumai">立即购买</a>
        {/if}
    </div>

    <div class="ftc_wzsf" >
        <div class="srzfmm_box">
            <div class="qsrzfmm_bt clear_wl">
                <img src="__MOBILE__/images/xx_03.jpg" class="tx close fl">
                <span class="fl">请输入支付密码</span></div>
            <div class="zfmmxx_shop">
                <div class="mz">￥123</div>
                <div class="zhifu_price"></div></div>
            <ul class="mm_box">
                <li></li><li></li><li></li><li></li><li></li><li></li>
            </ul>
        </div>
        <div class="numb_box">
            <div class="xiaq_tb">
                <img src="__MOBILE__/images/jftc_14.jpg" height="10"></div>
            <ul class="nub_ggg">
                <li><a href="javascript:void(0);" class="zf_num">1</a></li>
                <li><a href="javascript:void(0);" class="zj_x zf_num">2</a></li>
                <li><a href="javascript:void(0);" class="zf_num">3</a></li>
                <li><a href="javascript:void(0);" class="zf_num">4</a></li>
                <li><a href="javascript:void(0);" class="zj_x zf_num">5</a></li>
                <li><a href="javascript:void(0);" class="zf_num">6</a></li>
                <li><a href="javascript:void(0);" class="zf_num">7</a></li>
                <li><a href="javascript:void(0);" class="zj_x zf_num">8</a></li>
                <li><a href="javascript:void(0);" class="zf_num">9</a></li>
                <li><a href="javascript:void(0);" class="zf_empty">{:lang('清空')}</a></li>
                <li><a href="javascript:void(0);" class="zj_x zf_num">0</a></li>
                <li><a href="javascript:void(0);" class="zf_del">{:lang('删除')}</a></li>
            </ul>
        </div>
        <div class="hbbj"></div>
    </div>

{/block}
{block name="js"}
<script type="text/javascript">

    var mySwiper = new Swiper(".swiper-container",{
        direction:"horizontal",
        loop:true,
        pagination:".swiper-pagination",
        autoplay:3000,
        autoplayDisableOnInteraction : false,
    });

   $(".evals li").click(function(){
       var Oindex = $(this).index();
       $(".evals li").removeClass("active").eq(Oindex).addClass("active");
       $(".united").hide().eq(Oindex).show();
   });

   $(".jia").click(function(){
       $("#num").val( Number($("#num").val()) + 1);
   });
   $(".jian").click(function(){
       if($("#num").val() == 1){
           msg_alert("商品数量最少为1");
       }else{
            $("#num").val( Number($("#num").val()) - 1);
       }
       
   });

   function showParams(){
    var num = $("#num").val();
    console.log($("#num").val());
    var good_id=$('input[name="good_id"]').val();
    $.ajax({
             type: "POST",
             url: "/langjinmobile/Card/addcart",
             data: {'good_id':good_id,'num':num},
             dataType: "json",
             success: function(data){
                console.log(data);
                 if(data.status==1){
                    window.location.href="/langjinmobile/Card/shopcard";   
                 }else{
                     msg_alert(data.msg);
                 }

                　 
             }
         });
         return false;
   } 


   $("#goumai").click(function(){
       if($("#num").val() != 1){
           msg_alert("当前产品只能购买一件");
       }else{
        $(".ftc_wzsf").show();
        $(".mz").html($(".puct").find("p").eq(0).html());
       }
   
   });
</script>

<script type="text/javascript">
    $(function(){
    //关闭浮动
    $(".close").click(function(){
      $(".ftc_wzsf").hide();
      $(".mm_box li").removeClass("mmdd");
      $(".mm_box li").attr("data","");
      i = 0;
    });
      //数字显示隐藏
    $(".xiaq_tb").click(function(){
      $(".numb_box").slideUp(500);
    });
    $(".mm_box").click(function(){
      $(".numb_box").slideDown(500);
    });
      //----
    var i = 0;
    $(".nub_ggg li .zf_num").click(function(){
          var good_id=$('input[name="good_id"]').val();console.log(good_id);
      if(i<6){
          $(".mm_box li").eq(i).addClass("mmdd");
          $(".mm_box li").eq(i).attr("data",$(this).text());
          i++
          if (i==6) {
            setTimeout(function(){
              var pwd = "";
                  $(".mm_box li").each(function(){
                  pwd += $(this).attr("data");
              });
               $(".ftc_wzsf").hide();
              $("#loading").show();
              console.log(1);
                //ajax提交密码
                $.ajax({
                    url:'/langjinmobile/Card/zhipay',
                    type:'POST',
                    data:{'pwd':pwd,'good_id':good_id},
                    datatype:'json',
                    success: function(mes) {
                      console.log(mes);
                      
                        if(mes.status == 1){
                            window.location.href = "/langjinmobile/Card/paycom"; 
                            msg_alert(mes.msg);  
                            $(".ftc_wzsf").hide();
                            $(".mm_box li").removeClass("mmdd");
                            $(".mm_box li").attr("data","");
                            i = 0;
                        }else{
                            msg_alert(mes.msg);
                            $("#loading").hide();
                            $(".mm_box li").removeClass("mmdd");
                            $(".mm_box li").attr("data","");
                            i = 0;
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                      console.log(XMLHttpRequest.status);
                      console.log(XMLHttpRequest.readyState);
                      console.log(textStatus);
                      },
                })
            },1000);
          };
      }
    });
    $(".nub_ggg li .zf_del").click(function(){
      if(i>0){
          i--
          $(".mm_box li").eq(i).removeClass("mmdd");
          $(".mm_box li").eq(i).attr("data","");
      }
    });
    
    $(".nub_ggg li .zf_empty").click(function(){
      $(".mm_box li").removeClass("mmdd");
      $(".mm_box li").attr("data","");
      i = 0;
    });
    
    });
    </script>
{/block}